﻿using MyWeb.ScheduledTasks.Business.Job;
using MyWeb.ScheduledTasks.Models;
using MyWeb.ScheduledTasks.Protos;
using Quartz.Impl.Matchers;
using Quartz.Impl.Triggers;
using Quartz.Spi;
using Quartz;
using System.Collections.Generic;

namespace MyWeb.ScheduledTasks.Business
{
    public interface ITaskQuartService
    {
        /// <summary>
        /// 初始化作业
        /// </summary>
        /// <returns></returns>
        Task InitJobsAsync();
        /// <summary>
        /// 查询作业列表
        /// </summary>
        /// <returns></returns>
        Task<List<Jobs>> GetJobs();
        /// <summary>
        /// 添加任务
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> AddJob(Jobs request);
        /// <summary>
        /// 移除任务
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> Remove(Jobs request);
        /// <summary>
        /// 修改任务
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> Update(Jobs request);
        /// <summary>
        /// 暂停任务
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> Pause(Jobs request);
        /// <summary>
        /// 启动任务
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> Start(Jobs request);
        /// <summary>
        /// 运行一次任务
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> Run(Jobs request);
        /// <summary>
        /// 获取任务状态
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<string> GetState(Jobs request);
        /// <summary>
        /// 判断任务是否存在
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> IsQuartzJob(Jobs request);
        /// <summary>
        /// 验证Cron表达式是否正确
        /// </summary>
        /// <param name="request">Cron表达式</param>
        /// <returns></returns>
        bool IsValidExpression(string request);
        Task<List<TaskLog>> GetLog(long jobId, int page, int pageSize);
    }
}
